<?php
/***
 * Hipay线上充值抽奖
 */
$_GET['mid'] = 'DJEHBSUAAY';

ini_set("display_errors", "On");//开启错误显示
define('INDEX', true);
define('TaskName', 'Auto_Set_Pre2');
require_once dirname(__FILE__) . '/../../Lib/Sing_core.php';
@include libfile('function/api');

DB::SetMainDB(DB_ESHOP);
$crontab = DB::fetch_first("select * from %t where task_name=%s", array('crontab_exec', TaskName));
if ($crontab) {
    $taskStatus = $crontab['task_status'];
    if ($taskStatus) {
        exit;
    } else {
        DB::SetMainDB(DB_ESHOP);
        DB::update('crontab_exec', array(
            'task_status' => 1,
            'task_count' => $crontab['task_count'] + 1,
            'begin_time' => time()
        ), array(
            'task_name' => TaskName
        ));
    }
} else {
    DB::SetMainDB(DB_ESHOP);
    DB::insert('crontab_exec', array(
        'task_name' => TaskName,
        'task_func' => TaskName,
        'task_status' => 1,
        'begin_time' => time(),
        'close_time' => 0,
        'interval_time' => 0,
        'task_count' => 1
    ));
}
$xlapp = new api_shake();
$r = $xlapp->initPer2();
DB::SetMainDB(DB_ESHOP);
DB::update('crontab_exec', array(
    'task_status' => 0,
    'close_time' => time()
), array(
    'task_name' => TaskName
));

